﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using SomeRandomGame.Interfaces;
using SomeRandomGame.Utility;

namespace SomeRandomGame.Screens
{
    public class BackgroundScreen: GameScreen
    {
        private Texture2D _backgroundTexture;

        public BackgroundScreen()
        {
            TransitioningInTime = TimeSpan.FromSeconds( 0.5 );
            TransitioningOutTime = TimeSpan.FromSeconds( 0.5 );
        }

        public override void Initialize( IGameManager gameManager )
        {
            _backgroundTexture = gameManager.Game.Content.Load<Texture2D>( Constants.Content.Graphics.BACKGROUND_SCREEN );
        }

        public override void Update( GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen )
        {
            // false forces screen to stay even if it is covered by other screen
            base.Update( gameTime, otherScreenHasFocus, false );
        }

        public override void Draw( SpriteBatch spriteBatch, IGameManager gameManager, GameTime gameTime )
        {
            spriteBatch.Begin();
            spriteBatch.Draw( _backgroundTexture,
                              new Rectangle( 0, 0, gameManager.Game.GraphicsDevice.Viewport.Width,
                                             gameManager.Game.GraphicsDevice.Viewport.Height ),
                              new Color( TransitionAlpha, TransitionAlpha, TransitionAlpha ) );
            spriteBatch.End();
        }
    }
}
